package com.sgj.watchinyou.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.annotation.SuppressLint;
import android.net.ParseException;

@SuppressLint("SimpleDateFormat")
public class DateUtils {
	public static final String dateFormat = "yyyy-MM-dd HH:mm:ss";

	 public static final String dateFormat8 = "yyyyMMdd";
	 public static final String dateFormat14 = "yyyyMMddHHmm";
	 public static final String dateFormat15 = "yyyyMMdd'T'HHmmss";
	 public static final String dateFormat16 = "yyyyMMdd'T'HHmmss'Z'";

	 private DateUtils() {
	 }

	 /**
	  * @param date
	  * @param dateFormat
	  * @return java.lang.String
	  */
	public static String MilliSecondToString(Long date, String dateFormat) {

	  return date != null ? new SimpleDateFormat(dateFormat).format(date) : "";
	 }

	 /**
	  * @param date
	  * @param dateFormat
	  * @return java.util.Calendar
	 * @throws java.text.ParseException 
	  */
	 public static Long StringToMilliSecond(String date, String dateFormat) throws java.text.ParseException {
	  Calendar calendar = Calendar.getInstance();
	  try {
	   calendar.setTime(new SimpleDateFormat(dateFormat).parse(date));
	  } catch (ParseException e) {
	   e.printStackTrace();
	  }

	  return calendar.getTimeInMillis();
	 }
}
